<template>
  <div>
    <el-container>
      <el-header>
<!--        头部-->
        <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
          <el-menu-item index="1">处理中心</el-menu-item>
          <el-submenu index="2">
            <template slot="title">我的工作台</template>
            <el-menu-item index="2-1">选项1</el-menu-item>
            <el-menu-item index="2-2">选项2</el-menu-item>
            <el-menu-item index="2-3">选项3</el-menu-item>
            <el-submenu index="2-4">
              <template slot="title">选项4</template>
              <el-menu-item index="2-4-1">选项1</el-menu-item>
              <el-menu-item index="2-4-2">选项2</el-menu-item>
              <el-menu-item index="2-4-3">选项3</el-menu-item>
            </el-submenu>
          </el-submenu>
          <el-menu-item index="3" disabled>消息中心</el-menu-item>
          <el-menu-item index="4"><a href="https://www.ele.me" target="_blank">订单管理</a></el-menu-item>
        </el-menu>
      </el-header>
      <el-container>
        <el-aside width="202px">
<!--          侧边-->
            <el-col :span="12">
<!--              <h5>默认颜色</h5>-->
              <el-menu
                  :default-active=sideIndex
                  style="width: 200px"
                  class="el-menu-vertical-demo"
                  @open="handleOpen"
                  @close="handleClose">


                <el-menu-item index="1" @click="toHome()">
                  <i class="el-icon-orange"></i>
                  <span slot="title">仪表盘</span>
                </el-menu-item>

                <el-submenu index="2">
                  <template slot="title">
                    <i class="el-icon-s-operation"></i>
                    <span>总览</span>
                  </template>
                  <el-menu-item-group>
                    <template slot="title">小组管理</template>
                    <el-menu-item index="1-1">修改信息</el-menu-item>
                    <el-menu-item index="1-2">作业布置</el-menu-item>
                  </el-menu-item-group>
                  <el-menu-item-group title="用户">
                    <el-menu-item index="1-3">发送系统通知</el-menu-item>
                    <el-menu-item index="1-3">后面再想功能</el-menu-item>
                  </el-menu-item-group>
                </el-submenu>


                <el-menu-item index="3" @click="toApply()">
                  <i class="el-icon-document-copy"></i>
                  <span slot="title">管理申请</span>
                </el-menu-item>
                <el-menu-item index="4" @click="toDesk()">
                  <i class="el-icon-paperclip"></i>
                  <span slot="title">科队桌子</span>
                </el-menu-item>
                <el-menu-item index="5" @click="toUser()">
                  <i class="el-icon-setting"></i>
                  <span slot="title">操作用户</span>
                </el-menu-item>


              </el-menu>
            </el-col>
        </el-aside>
        <el-main class="databody">

<!--          使用路由-->
          <router-view/>

        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "fremwork",
  data() {
    return {
      activeIndex: '1',
      activeIndex2: '1',
      sideIndex:'0'
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key,keyPath)
      // this.$router.push({ path: '/home' })
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    },
    toHome(){
      const matchedComponents = this.$router.getMatchedComponents();
      if(matchedComponents[1].name!="Home"){
        this.$router.push({path:'/home'})
      }
    },
    toApply(){
      const matchedComponents = this.$router.getMatchedComponents();
      if(matchedComponents[1].name!="ApplyControl"){
        this.$router.push({path:'/applyControl'})
      }
    },
    toDesk(){
      const matchedComponents = this.$router.getMatchedComponents();
      if(matchedComponents[1].name!="DeskControl"){
        this.$router.push({path:'/deskControl'})
      }
    },
    toUser(){
      const matchedComponents = this.$router.getMatchedComponents();
      if(matchedComponents[1].name!="UserControl"){
        this.$router.push({path:'/userControl'})
      }
    }
  }
}
</script>

<style scoped>
.databody{

}
</style>